<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body{
            margin:0;
        }
        div {
            float: left;
        }
    </style>
</head>
<body>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<h2>aaa</h2>
<div>
    <img src="image/a.png">
    <img src="image/a.png">
    <img src="image/a.png">
</div>
<div id="mm" style="position: relative">
    <p>aa</p>
    <div style="position: relative">
        <img src="image/b.png" id="b">
    </div>
</div>
<script>
    var b = document.getElementById('b');
    function getAbsOffset(obj){
        function getAbsOffsetX(obj){
            var x = 0;
            if (obj){
                return x + obj.offsetLeft + getAbsOffsetX(obj.offsetParent);
            } else {
                return 0;
            }
        }
        function getAbsOffsetY(obj){
            var y = 0;
            if (obj){
                return y + obj.offsetTop + getAbsOffsetY(obj.offsetParent);
            } else {
                return 0;
            }
        }
        return {
            left:getAbsOffsetX(obj),
            top:getAbsOffsetY(obj),
        }
    }
    var bInfo = getAbsOffset(b);
    console.log(bInfo);
</script>


</body>
</html>